﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ReportModel>" %>

<%@ Import Namespace="ReportService.Models" %>
<%@ Import Namespace="ReportService.Models.ViewModels" %>
<div>
<% using (Ajax.BeginForm("ShowSummaryReport", "Report", null, new AjaxOptions { HttpMethod = "post", UpdateTargetId = "ReportViewPlace" }))
    { %>
    <div class="head">
        <h3>
            REPORT ENERGY COMSUMMING SUMMARY
        </h3>
    </div>

    <div class="labelcol">
        <label>Year:</label>
    </div>
    <div class="valuecol">
        <%: Html.DropDownListFor(m => m.SummaryReport.YearOfReport, Model.ListReportYears, new { @id = "reportYear", @style = "width:200px;" })%>
    </div>

    <div class="clear_both"></div>

    <div class="labelcol">
        <label>Store:</label>
    </div>
    <div class="valuecol">
        <div id="listStore" class="list-container">        
        <% foreach (GetStoresByNameResult store in Model.ListAllStores)
           { %>
            <input type="checkbox" value='<%= store.StoreName %>' checked="checked" onclick='onChecked(this, "hdListExceptStore")' /><%= store.StoreName %><br />
        <% } %>
        </div>
        <%: Html.HiddenFor(m => m.SummaryReport.ListExceptStore, new { @id = "hdListExceptStore" })%>
    </div>    
    <div class="clear_both"></div>
    
    <div class="foot">
        <input type="button" id="btnShowSummaryReport" value="Show Data" onclick='OnShowData("hiddenSubmitSummaryReport")' />
        <input type="button" id="btnExportSummaryReport2Excel" value="Export Excel" />
        <input type="submit" id="hiddenSubmitSummaryReport" style="display:none;" />
    </div>
    <script language="javascript" type="text/javascript">
        $(function () {
            //Report 2 excel 
            $('#btnExportSummaryReport2Excel').click(function () {
                //$("form[action$='ShowSummaryReport']").attr("action", "SummaryReport2Excel");
                var form = $("form[action$='ShowSummaryReport']")[0];
                form.setAttribute("action", "/ReportController/SummaryReport2Excel");
                $('#hiddenSubmitSummaryReport').click();
            });
        });
    </script>    
<%  } %>
</div>